﻿YUI.add('prevaluacion-view', function (Y) {
    'use strict';
    Y.Prevaluacion = Y.Base.create('Prevaluacion', Y.View, [], {
        templateIsCharged: false,
        loadTemplate: function () {
            if (this.template == '') {
                var that = this,
                validator = null,
                request = Y.io('/ExcellentProject/scripts/views/evaluaciones/evaluaciones/templates/prevaluacion.html', {
                    on: {
                        complete: function (id, response) {
                            that.templateIsCharged = true;
                            that.template = response.responseText;
                            that.render();
                        }
                    },
                    failure: function (id, response) {
                        alert(response)
                    }
                })
            }
        },
        render: function () {
            this.loadTemplate();
            if (this.templateIsCharged) {
                var contentTemplate = Y.Handlebars.compile(this.template);

                this.get('container').setHTML(contentTemplate(this.get('model')));
                
            }
        }
    })

}, '0.0.0.1', { requires: ['view', 'handlebars', 'node', 'event', 'node-event-simulate', 'examen-model', 'handlebars-customif-helper'] })